<template>
  <aside class="side-nav-bar">
    <div class="nav-bar-item"
         :class="{active: currentIndex === index}"
         v-for="(item, index) in categoryList"
         :key="index"
         @click="itemClick(index, item)">
      {{item.title}}
    </div>
  </aside>
</template>

<script>
export default {
  name: "SideNavBar",
  data() {
    return {
      currentIndex: 0,
    }
  },
  props: {
    categoryList: {
      type: Array,
      default() {
        return []
      }
    }
  },
  methods: {
    itemClick(index ,item) {
      this.currentIndex = index;
      this.$emit('itemClick', item)
    }
  }
}
</script>

<style scoped>
  .side-nav-bar {
    height: calc(100vh - 89px);
    background-color: #f6f6f6;
  }
  .nav-bar-item {
    height: 32px;
    line-height: 32px;
    text-align: center;
    font-size: 14px;
  }
  .active {
    background-color: #fff;
    border-left: 4px solid var(--color-high-text);
    color: var(--color-high-text);
  }
</style>